package com.zlzxm.shoesmarket.view.adapter;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.zlzxm.shoesmarket.R;
import com.zlzxm.shoesmarket.view.adapter.entity.EntityMarketInfo;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * Created by zlz
 * on  4/12/21
 * todo recyclerview 嵌套 需要 再斟酌下
 */
public class ADMarketInfo extends BaseQuickAdapter<EntityMarketInfo, BaseViewHolder> {
    public ADMarketInfo( @Nullable List<EntityMarketInfo> data) {
        super(R.layout.item_market_info, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, EntityMarketInfo entity) {

        holder.setText(R.id.tvMarketName,entity.getName());

        ADMarketMark adMarketMark = new ADMarketMark(entity.getMarks());

        RecyclerView rvMarks = holder.getView(R.id.rvMarks);
        rvMarks.setLayoutManager(new LinearLayoutManager(getContext(),RecyclerView.HORIZONTAL,false));
        rvMarks.setAdapter(adMarketMark);


        ADMarketGoods adMarketGoods = new ADMarketGoods(entity.getGoods());

        RecyclerView rvGoods = holder.getView(R.id.rvGoods);
        rvGoods.setLayoutManager(new GridLayoutManager(getContext(),4));
        rvGoods.setAdapter(adMarketGoods);

    }
}
